package own.thread.mworker;

import java.util.Map;

public class Test {


	public static void main(String[] args) {
		long start=System.currentTimeMillis();
		long l=0l;
//		for(int i=0;i<1000;i++){
//			l+=i*i*i;
//		}
		Master m = new Master(new PlusWorker(), 4); 
		for(int i=0;i<1000;i++){
			m.submit(i);
		}
		m.execute();
		Map<String ,Object> resultMap= m.getResultMap();  
		while(true){
			if(m.isComplete()){
				for(Map.Entry<String ,Object> r:resultMap.entrySet()){
					
					l+=(Integer)r.getValue();
					resultMap.remove(r.getKey());
				}
				break;
			}
		}
		System.out.println(l);
		System.out.println("time==="+(System.currentTimeMillis()-start));
	}
}
